package com.hschinese.pronunciation.model;

import com.hschinese.pronunciation.bean.UserInfo;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by wo on 2015/11/13.
 */
public class UserInfoModel {
    /**
    {
        "User":
        {
            "Picture":"http:\/\/hschinese.com\/\/sites\/all\/themes\/hellohsk\/images\/portrait.png",
                "Name":"xionghy2014",
                "Enabled":"1",
                "Nickname":"xionghy2014",
                "Email":"xionghy2014@163.com",
                "Avatars":"http:\/\/hschinese.com\/\/sites\/all\/themes\/hellohsk\/images\/portrait.png",
                "Image":"http:\/\/hschinese.com\/\/sites\/all\/themes\/hellohsk\/images\/portrait.png",
                "Enddate":"2015-11-13",  ---------------------------
                "Role":"",
                "EndTime":0,
                "Balance":"100",
                "Uid":"235324"
        },"Success":true, "Message":"Login succeeds."}*/
    private static UserInfoModel mInstance = null;
    private UserInfoModel() {
    }

    public static UserInfoModel getInstance() {
        synchronized (UserInfoModel.class) {
            if (mInstance == null) {
                mInstance = new UserInfoModel();
            }
            return mInstance;
        }
    }

    public UserInfo getUserInfoObj(JSONObject json) throws JSONException {
        UserInfo info = new UserInfo();
        info.setPicture(json.getString("Picture"));
        info.setName(json.getString("Name"));
        info.setNickname(json.getString("Nickname"));
        info.setEmail(json.getString("Email"));
        info.setNemail(json.getString("Email"));
        info.setImage(json.getString("Avatars"));
        info.setEndTime(json.getString("EndTime"));
        info.setRole(json.getString("Role"));
        info.setBalance(json.getString("Balance"));
        info.setUid(json.getString("Uid"));
        info.setAvatars(json.getString("Avatars"));
        info.setEndDate(json.getString("Enddate"));
        return info;
    }
}
